/*
 * Message.h
 *
 *  Created on: 2012-7-16
 *      Author: guanlei
 */

#ifndef MESSAGE_H_
#define MESSAGE_H_
#include "../net/msg.h"
#include "chat_server_define.h"
#pragma pack(1)
enum{
	MSG_LOGIN_CHAT_CHANNEL = 1000,
	CHAT_JOIN_CHANNEL_SUCCESS,
	CHAT_CLIENT_JOIN_CHANNEL,
	CHAT_CLIENT_JOIN_CHANNEL_ACK,
	CHAT_MSG,//用户发送的消息
	MSG_RECV, //发送给用户的消息
	GM_SM		//GM的消息
};

struct cmdChannelInfo{
	CHANNEL_ID		channel_id;
	char			channel_name[20];
	unsigned short 	online_num;
};

//所有的聊天频道信息
struct cmdChatWorldInfo:MsgBase{
	int 			user_id;
	unsigned short	current_chater_online_num;
	unsigned short	total_channle_num;
	char			data[1];
};

//用户登录聊天频道
struct ChaterLoginChatChannel:MsgBase{
	int 	user_id;
	char	user_name[20];
	short	world_id;
	int 	login_chat_channel_id;
	int	rand_index;
	int	zeit;
	char    login_validate_code[16];
	ChaterLoginChatChannel(){
		msg_type = MSG_LOGIN_CHAT_CHANNEL;
		memset(user_name,0,20);
		memset(login_validate_code,0,16);
	}

};

//成功登陆聊天服务器
struct ChaterSuccessLogin:MsgBase{
	CHATER_ID 	user_id;
	CHANNEL_ID	channel_id;
	int		time_stamp;
	bool		login_rst;
	ChaterSuccessLogin(){
		msg_type = CHAT_JOIN_CHANNEL_SUCCESS;
		msg_size = sizeof(ChaterSuccessLogin);
	}
};

//申请加入频道
struct ChaterRequestJoinChannel:MsgBase{
	CHATER_ID 	user_id;
	short		world_id;
	CHANNEL_ID 	channel_id;
	ChaterRequestJoinChannel(){
		msg_type = CHAT_CLIENT_JOIN_CHANNEL;
		msg_size = sizeof(ChaterRequestJoinChannel);
	}
};

//
struct ChaterRequestJoinChannelAck:MsgBase{
	CHATER_ID 	user_id;
	CHANNEL_ID	channel_id;
	bool	rst;
	ChaterRequestJoinChannelAck(){
		msg_type = CHAT_CLIENT_JOIN_CHANNEL_ACK;
		msg_size = sizeof(ChaterRequestJoinChannelAck);
	}
};

//聊天用户的消息
struct UserChatMsg:MsgBase{
	short   world_id;
	int 	sender_id;
	int	recv_target_id;
	int	send_zeit;
	short 	message_type;
	short	message_len;
	char 	message_content[];
	UserChatMsg(){
		msg_type = CHAT_MSG;
		msg_size = message_len +  sizeof(UserChatMsg) - sizeof(char*);
		is_encode = false;
	}
};

//禁言
struct GmFribbenMsg:MsgBase{
	int	zone_id;
	int	player_id;
	int	fribben_zeit;
	GmFribbenMsg(){
		msg_type = GM_SM;
		msg_size = sizeof(GmFribbenMsg);
	}
};

#pragma pack()
#endif /* MESSAGE_H_ */
